package com.esri.android.action;

import android.content.Context;
import android.database.DataSetObserver;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import com.esri.core.io.EsriServiceException;
import com.esri.core.tasks.identify.IdentifyResult;
import java.util.ArrayList;
import java.util.List;

/* loaded from: classes.dex */
public class IdentifyResultSpinnerAdapter implements SpinnerAdapter {
    List<IdentifyResult> a;
    Context b;

    @Override // android.widget.Adapter
    public long getItemId(int i) {
        return i;
    }

    @Override // android.widget.Adapter
    public int getItemViewType(int i) {
        return 0;
    }

    @Override // android.widget.Adapter
    public int getViewTypeCount() {
        return 1;
    }

    @Override // android.widget.Adapter
    public boolean hasStableIds() {
        return false;
    }

    @Override // android.widget.Adapter
    public boolean isEmpty() {
        return false;
    }

    @Override // android.widget.Adapter
    public void registerDataSetObserver(DataSetObserver dataSetObserver) {
    }

    @Override // android.widget.Adapter
    public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
    }

    public IdentifyResultSpinnerAdapter(Context context, List<IdentifyResult> list) {
        if (context != null) {
            this.b = context;
            if (list != null) {
                this.a = list;
                return;
            } else {
                this.a = new ArrayList();
                return;
            }
        }
        throw new EsriServiceException("The mContext cannot be null");
    }

    @Override // android.widget.Adapter
    public int getCount() {
        return this.a.size();
    }

    @Override // android.widget.Adapter
    public Object getItem(int i) {
        return this.a.get(i).getLayerName();
    }

    @Override // android.widget.Adapter
    public View getView(int i, View view, ViewGroup viewGroup) {
        String layerName;
        TextView textView;
        IdentifyResult identifyResult = this.a.get(i);
        if (identifyResult.getAttributes().containsKey(identifyResult.getDisplayFieldName())) {
            layerName = (String) identifyResult.getAttributes().get(identifyResult.getDisplayFieldName());
        } else {
            layerName = identifyResult.getLayerName();
        }
        if (view == null || !(view instanceof TextView)) {
            textView = new TextView(this.b);
        } else {
            textView = (TextView) view;
        }
        textView.setText(layerName);
        textView.setTextColor(-16777216);
        textView.setLayoutParams(new AbsListView.LayoutParams(-1, -2));
        textView.setGravity(16);
        return textView;
    }

    @Override // android.widget.SpinnerAdapter
    public View getDropDownView(int i, View view, ViewGroup viewGroup) {
        TextView textView = (TextView) getView(i, view, viewGroup);
        textView.setTextSize(20.0f);
        textView.setMinHeight(50);
        return textView;
    }
}
